home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacWorld: Complete Mac Interactive
/
Macworld Complete Mac Interactive CD)(1994).iso
/
The Best of BMUG
/
Utilities
/
Text and Speech
/
Alpha.5.76
/
Tcl
/
SystemCode
/
filesets.tcl
< prev
next >
Wrap
Text File
|
1994-03-11
|
4KB
|
126 lines
#===============================================================================================
# Create new filesets either by the "Utils:Add Fileset..." menu item. These
# filesets can be made permanent by "Utils:Dump Fileset..."ing the fileset
# to immediately below.
#
# Alpha calls two fileset-related routines, 'getCurrFileSet', and
# 'getFileSetNames'. Alpha will also attempt to set the variable 'currFileSet'
# on occasion, but this isn't critical.
#===============================================================================================
#===========================================================================
# The filesets.
#===========================================================================
# Build some filesets on the fly.
catch {unset fileSets}
catch {unset currFileSet}
catch {set fileSets(HomeDir) [glob -t TEXT "$HOME:*"]}
catch {set fileSets(Help) [glob -t TEXT "$HOME:*"]}
catch {set fileSets(System) [glob -t TEXT "$HOME:Tcl:SystemCode:*.tcl"]}
catch {set fileSets(User) [glob -t TEXT "$HOME:Tcl:UserCode:*.tcl"]}
set currFileSet ""
#===========================================================================
# The support routines.
#===========================================================================
# Called from Alpha to get list of files for current file set.
proc getCurrFileSet {} {
global fileSets
global currFileSet
return $fileSets($currFileSet)
}
# Called from Alpha to get names. The first name returned is taken to
# be the current fileset.
proc getFileSetNames {} {
global fileSets
global currFileSet
set ind [lsearch [array names fileSets] $currFileSet]
if {$ind < 0} {set ind 0}
return [linsert [lsort [lreplace [array names fileSets] $ind $ind]] 0 $currFileSet]
}
# Keep 'sets' menu up to date.
trace vdelete currFileSet w shadowCurrFileSet
trace variable currFileSet w shadowCurrFileSet
proc shadowCurrFileSet {nm1 nm2 op} {
global fileSets
global currFileSet
foreach name [array names fileSets] {
if {$name == $currFileSet} {
markMenuItem -m choose $name on
} else {
markMenuItem -m choose $name off
}
}
return $currFileSet
}
# Called in response to user changing filesets from the fileset menu.
proc changeFileSet {menu item} {
global currFileSet
markMenuItem -m choose $currFileSet off
set currFileSet $item
markMenuItem -m choose $currFileSet on
}
#===========================================================================
# Add fileset.
#===========================================================================
proc createFileset {} {
global fileSets
global currFileSet
set name [getline "New fileset name:" ""]
if {![string length $name]} return
set dir [string trim [get_directory] ":"]
if {![string length $dir]} return
set filePat [getline "File pattern:" "*"]
if {![string length $filePat]} return
set "fileSets($name)" [glob -t TEXT "$dir:$filePat"]
menu -n choose -m -p changeFileSet [lsort [array names fileSets]]
set currFileSet $name
if {[askyesno "Save new fileset?"] == "yes"} {
addUserLine "set \"fileSets($name)\" \[glob -t TEXT \"$dir:$filePat\"\]"
addUserLine "addMenuItem choose \"$name\""
}
}
#===========================================================================
# Dump fileset to current window. If you dump at the end of this file,
# the fileset will be reloaded the next time you run Alpha.
#===========================================================================
proc dumpFileset {} {
global fileSets
global currFileSet
if {![catch {prompt "Fileset name:" $currFileSet} name]} {
insertText "set \"fileSets($name)\" \{\r"
foreach file "$fileSets($name)" {
insertText "\t\"$file\"\r"
}
insertText "\}\r"
}
}
#===========================================================================
# Must stay the last thing in the file! We need this so that all the
# filesets defined above make it into the menu.
#===========================================================================
menu -n choose -m -p changeFileSet [lsort [array names fileSets]]
markMenuItem -m choose $currFileSet on